-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: skip unnecessary test runs for bot-generated and non-critical PRs #1339
base: master
Are you sure you want to change the base?
Conversation
Fix/skip unnecessary tests
docs: update README.md for testing
Update pr-testing-with-test-project.yml
Update pr-testing-with-test-project.yml
|
Hey @derberg ,done with the changes in the required file , do let me know of any further changes . Thanks |
LGTM :) |
Hey @derberg can you run the workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing PR @AdityaP700 just few suggestions to improve it more.
should-test: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
run_tests: ${{ steps.check.outputs.run_tests }} | ||
steps: | ||
- name: Check if tests should run | ||
id: check | ||
run: | | ||
# Skip for bot PRs with specific titles | ||
if [[ "${{ github.actor }}" == "asyncapi-bot" && "${{ github.event.pull_request.title }}" =~ ^(ci:\ update|chore\(release\):) ]] || \ | ||
[[ "${{ github.actor }}" == "allcontributors[bot]" && "${{ github.event.pull_request.title }}" =~ ^docs: ]]; then | ||
echo "run_tests=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "run_tests=true" >> $GITHUB_OUTPUT | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a new job on which the actual job to be done is dependent won't increase job setup time?
Instead, how's about adding an if clause just like it is done here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did tried adding but thought of optimising it a bit thus made it likewise ,anyway will look into it .
test: | ||
if: github.event.pull_request.draft == false | ||
needs: should-test | ||
if: needs.should-test.outputs.run_tests == 'true' && github.event.pull_request.draft == false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if: needs.should-test.outputs.run_tests == 'true' && github.event.pull_request.draft == false | |
if: needs.should-test.outputs.run_tests == true && github.event.pull_request.draft == false |
wrapping true
in single quotes makes it string, although eventually, it results in a true statement (as strings are also considered to be true) so the workflow works as expected. But it's a good practice to use Booleans for truthy and falsy statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright got it !! i took the assumptions so did such changes but anyway will resolve it .
README.md
Outdated
@@ -8,7 +8,7 @@ This is a Monorepo managed using [Turborepo](https://turbo.build/) and contains | |||
|
|||
1. [Hooks](apps/hooks): This library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. Hooks are designed to let template developers hook into the template generation process. For example, one can create a hook code that will be automatically invoked right after the template generation process has ended. | |||
|
|||
1. [Nunjucks-filters](apps/nunjucks-filters): This library contains generator filters that can be reused across multiple templates, helping to avoid redundant work. These filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies separately. | |||
1. [Nunjucks-filters](apps/nunjucks-filters): This library contains generator filters that can be reused across multiple templates helping to avoid redundant work. The filters are designed specifically for Nunjucks templates and are included by default with the generator, so there's no need to add them to dependencies separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pardon me : will discard the commit of it !!
|
||
jobs: | ||
test: | ||
if: github.event.pull_request.draft == false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should stay, we do not want to run this on drafts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright then ,will fix it accordingly.
run: echo "shouldrun=true" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- if: steps.should_run.outputs.shouldrun == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use 'true'
like in other workflows.
technically output of run: echo "shouldrun=true" >> $GITHUB_OUTPUT
is string -> https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#outputs-for-docker-container-and-javascript-actions
so also technically please compare with true that is represented as string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused at first as everywhere i was getting the response to use it as a string but since i was adviced to use it as a boolean expression so thought to implement it . Well will update it soon
@@ -4,10 +4,17 @@ name: Test using test project | |||
on: | |||
pull_request: | |||
types: [opened, reopened, synchronize, ready_for_review] | |||
paths: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is an interesting approach, any examples in production? how it works for others? like what was the inspiration?
so far we used only the "inclusion" part, not "exclusion"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach was inspired by use cases where filtering out certain paths or scenarios is critical to avoid unintended actions. The idea aligns with scenarios where 'exclusion' can complement 'inclusion' for more precise control in the reference of https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-including-paths : so thus had the idea of implementing the same here in the workflow.
Quality Gate passedIssues Measures |
Description
Related Issue(s)
Fixes Improve testing speed by skipping it for certain PRs #1335
Testing